Skip to content

HDDS-13063. Support splitting json output to multiple valid json files in a directory#10604

Open
prathmesh12-coder wants to merge 1 commit into
apache:masterfrom
prathmesh12-coder:HDDS-13063
Open

HDDS-13063. Support splitting json output to multiple valid json files in a directory#10604
prathmesh12-coder wants to merge 1 commit into
apache:masterfrom
prathmesh12-coder:HDDS-13063

Conversation

@prathmesh12-coder

Copy link
Copy Markdown

What changes were proposed in this pull request?

ozone debug replicas verify currently prints all verification results as one large JSON to stdout.
This PR adds support for writing output to a directory as multiple valid JSON files, similar to ozone debug ldb scan.

below options are added:

  • --out / -o: output directory. If it does not exist, it is created. If it already exists, it is reused.
  • --max-records-per-file: maximum number of keys per file.
    When set, output is split into files like dirName.0, dirName.1 etc. Each file is valid JSON with a keys array.

If --out is not used, the command still prints JSON to stdout as before.

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-13063

How was this patch tested?

  • Added integration tests in TestOzoneDebugReplicasVerify:


    • testSplitOutputToNewDirectory — verifies the command creates a non-existent output directory and splits the output across the expected number of valid JSON files, 
with each file respecting --max-records-per-file.
    • testSplitOutputToExistingDirectory — verifies the same behaviour when the output directory already exists.

  • Verified split files are valid JSON, respect --max-records-per-file, and contain all keys.

  • Manually tested in local docker-compose Ozone cluster: 


ozone debug replicas verify <vol>/<bucket> --checksums --all-results -o <dir path> --max-records-per-file <no. of keys per file>


confirmed the directory is created, the output is split into numbered valid JSON files, and the run summary is printed.

@adoroszlai adoroszlai added the tools Tools that helps with debugging label Jul 4, 2026

@sreejasahithi sreejasahithi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @prathmesh12-coder for the PR.
Left few comments.

* Writes verification output to file(s) instead of stdout.
* When recordsPerFile is greater than zero, the keys are split into multiple valid JSON files.
*/
private void writeOutputToFiles(ObjectNode root, ArrayNode keysArray, boolean allKeysPassed) throws IOException {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

writeOutputToFiles only writes new files, it never deletes existing ones. A re-run overwrites .0, .1, … but leaves higher numbered files from a prior run. This can be confusing to the user.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When --out is used with --max-records-per-file, each split file only contains:
{ "keys": [ ... ] }

But stdout and single-file --out (without splitting) include a top-level "pass" field:
{ "pass": true/false, "keys": [ ... ] }

So the JSON shape is inconsistent across output modes. If someone parses the split files, they can’t see the overall pass/fail result unless they check each key’s "pass".

Not sure if this is intentional. If split files are meant to be key-only chunks, a short note in the help text would help. If all modes should match, consider adding top-level "pass" to split files too (or writing a small summary file).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests cover split output (--out + --max-records-per-file) but not single-file --out alone. You could add a test for this case aswell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tools Tools that helps with debugging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants